﻿using System.Net;

namespace RFIDStation.DeviceDriver.Dtos;

public partial class MsgDto
{
    [JsonProperty( "cmd" )]
    public string Cmd { get; init; }

    [JsonProperty( "time" )]
    public long Time { get; init; } = DateTime.Now.ToUnixTimeMilliseconds( );

    /// <summary>
    /// 数据
    /// </summary>
    [JsonProperty( "data" )]
    public Dictionary<string, object> Data { get; set; } = new Dictionary<string, object>( );

    [JsonProperty( "status" )]
    public int Status { get; set; } = (int)HttpStatusCode.OK;

    [JsonProperty( "error" )]
    public string Error { get; set; }
}

partial class MsgDto
{
    public string ToJson( ) => JsonConvert.SerializeObject( this );
}
